import React, {Component , Fragment} from 'react';
import {Redirect, Route, Switch} from 'react-router-dom';
import NotFound404 from '../../common/404/index'
import routers from './routers';

export default class CRouter extends Component {
    componentDidMount(){
    }
    // 组件销毁前移除事件监听
    
    render() {
        return (
            <Fragment>
                <Switch>
                    {routers.map((e, i) => (
                        <Route
                            key={i}
                            path={e.path}
                            exact={e.exact}
                            component={e.component}
                        >
                            {i.title}
                        </Route>
                        ))
                    }
                    <Route render={() => <Redirect to="/404" exact component={NotFound404}/>} />
                </Switch>
            </Fragment>
        );
    }
}